package serializable;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;

import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;

import domain.SystemHistory;

public class Serializable {
	
	public static void saveSystemHistory(SystemHistory systemHistory) throws IOException{
		XMLResource xmlResource = new  XMLResourceImpl();
		xmlResource.setEncoding("UTF-8");
		xmlResource.getContents().add(systemHistory);
		
		StringWriter result = new StringWriter();
		xmlResource.save(result, null);
		
		PrintWriter print = new PrintWriter (new FileOutputStream("systemHistory.xml",false),false);     
		print.print(result.getBuffer().toString());   
		print.close();
	}

}
